{% extends 'admin/base.html' %}

{% block content %}
    <div class="tpl-content-wrapper">
        <div class="tpl-content-page-title">任务管理</div><br>
        <div class="tpl-portlet-components">
            <div class="portlet-title">
                <div class="caption font-green bold">任务列表</div>
            </div>
            <div class="tpl-block">
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-md-6">
                        <div class="am-btn-toolbar">
                            <div class="am-btn-group am-btn-group-xs">
                                <a type="button" class="am-btn am-btn-default am-btn-success" href=""><span class="am-icon-plus"></span> 新增</a>
                                <h5 class="am-text-danger">注意：如果不清楚这是什么，不要乱动</h5>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="am-g">
                    <div class="am-u-sm-12">
                            <table class="am-table am-table-striped am-table-hover table-main">
                                <thead>
                                    <tr>
                                        <th class="table-title">名字</th>
                                        <th class="table-title">下次运行</th>
                                        <th class="table-set">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {% for job in jobs %}
                                    <tr>
                                        <td>{{ job.id }}</td>
                                        <td>{{ job.next_run_time.strftime("%Y-%m-%d %H:%M:%S") }}</td>
                                        <td>
                                            <div class="am-btn-toolbar">
                                                <div class="am-btn-group am-btn-group-xs">
{#                                                    <a type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" style="background-color: rgb(255, 255, 255);" href="{{ url_for('admin.task_switch', job_id=job.id) }}">#}
{#                                                        {% if job.pending %}#}
{#                                                            <span class="am-icon-refresh"></span> 恢复#}
{#                                                        {% else %}#}
{#                                                            <span class="am-icon-pause"></span> 暂停#}
{#                                                        {% endif %}#}
{#                                                    </a>#}
                                                    <form class="am-btn-group" method="post" action="{{ url_for('.task_delete', job_id=job.id) }}">
                                                        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
                                                        <button type="submit" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" onclick="return confirm('确定要删除吗');">
                                                            <span class="am-icon-trash-o"></span> 删除
                                                        </button>
                                                    </form>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                    {% endfor %}
                                </tbody>
                            </table>
                    </div>

                </div>
            </div>
        </div>
    </div>
{% endblock %}